package com.soft.javase.day06;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;


/**
 * @author yzg
 * @desc TODO
 * @date 2025/4/24
 */
public class DateDemo1 {
    public static void main(String[] args) throws ParseException {
        System.out.println("----2014-5-25到2012-12-28中间有多少天----");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = sdf.parse("2014-05-25");
        Date date2 = sdf.parse("2012-12-28");
        long ms = date1.getTime() - date2.getTime();

        System.out.println("天数差: " + ms/(24*60*60*1000) + " 天");


        System.out.println("----距离当前时间500天后的日期和时间、星期----");

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_YEAR,500);
        Date date = calendar.getTime();
        String dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EEEE").format(date);

        System.out.println(dateStr);


        System.out.println("----你出生的当天是星期几----");

        Calendar calendar1 = Calendar.getInstance();
        calendar1.set(2001,Calendar.JUNE,30);
        Date date3 = calendar1.getTime();
        String date3Str = new SimpleDateFormat("yyyy-MM-dd 是 EEEE").format(date3);
        System.out.println(date3Str);
    }
}

